<template>
  <view class="user-order" :style="[outModuleCss]">
    <view :style="[moduleBgCss]" class="module-bg"></view>
    <view class="order-box">
      <view class="content-header" v-show="showHeader" @click="gotoOrderList">
        <moduleHeader
          :propsData="propsData"
          :moduleName="moduleName"
          :moreText="$t('person.allOrder')"
        ></moduleHeader>
      </view>
      <view class="split-line" v-show="showHeader"></view>
      <view class="content-body">
        <view class="tabs-list">
          <view
            class="tab-item"
            v-for="(item, index) in tabsList"
            :key="index"
            @click="handleTabItem(item, index)"
          >
            <view class="tab-img">
              <image
                :src="
                  item.tabImg ||
                  'https://chidian.chixiaodian.com/web/uploads/images/store_1/2021-10-21/b81e3fdcdd8306e4b3ea6dae70412fd6d21922e4.png'
                "
              />
              <view
                class="tab-tip-text"
                v-if="item.tabNum && item.tabNum != 0"
                >{{ item.tabNum }}</view
              >
            </view>
            <view class="tab-text" :style="{ color: fontColor }">{{
              item.tabText
            }}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { diySysPageMixin } from "../../mixins/index";
import moduleHeader from "@/components/diyNew/components/moduleHeader/index.vue";

export default {
  props: {
    propsData: {
      type: Object,
      default: () => {
        return {};
      },
    },
    myInfo: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  components: {
    moduleHeader,
  },
  mixins: [diySysPageMixin], //混入文件
  watch: {},
  data() {
    return {};
  },
  computed: {
    moduleName() {
      return this.propsData.params.moduleName;
    },
    showHeader() {
      return this.propsData.params.showText;
    },
    tabsList() {
      let arr = this.propsData.params.tabsList;
      arr.forEach((d, index) => {
        let keyText = "status_" + index;
        d["tabNum"] = this.myInfo.order_count[keyText];
      });
      return arr;
    },
    fontColor() {
      return this.propsData.params.fontColor;
    },
  },
  methods: {
    // 点击tab
    handleTabItem(item, index) {
      if (index == 4) {
        this.$utils.toUrl(
          "/order/order-refund-list/order-refund-list",
          "navigate"
        );
        return;
      }
      this.$utils.toUrl(`/order/order/order?status=${index}`, "navigate");
    },
    gotoOrderList() {
      this.$utils.toUrl("/order/order/order", "navigate");
    },
  },
  filters: {},
  mounted() {},
};
</script>

<style scoped lang="scss">
.user-order {
  width: 100%;
  position: relative;
  border-radius: 2.67vw;
  overflow: hidden;
  .order-box {
    width: 100%;
    .content-header {
      width: 100%;
      padding: 2.67vw 3.2vw;
      position: relative;
    }
    .split-line {
      width: 93.3%;
      height: 1px;
      background-color: #f1f1f1;
      margin: 0 auto;
    }
    .content-body {
      width: 100%;
      padding: 2.93vw 3.2vw;
      .tabs-list {
        display: flex;
        align-items: center;
        .tab-item {
          width: 20%;
          flex-shrink: 0;
          display: flex;
          flex-direction: column;
          align-items: center;
          position: relative;
          .tab-img {
            width: 6.67vw;
            height: 6.67vw;
            position: relative;
            .tab-tip-text {
              width: 3.467vw;
              height: 3.467vw;
              background: #f73119;
              border-radius: 50%;
              text-align: center;
              line-height: 3.467vw;
              font-size: 2.67vw;
              font-family: PingFang SC;
              font-weight: 600;
              color: #ffffff;
              position: absolute;
              right: -1.7335vw;
              top: -1.7335vw;
              z-index: 11;
            }
            image {
              width: 100%;
              height: 100%;
              display: block;
            }
          }
          .tab-text {
            font-size: 3.2vw;
            font-family: PingFang SC;
            font-weight: 400;
            color: #414141;
            margin-top: 1.6vw;
          }
        }
      }
    }
  }

  .module-bg {
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
  }
}
</style>
